package com.rocketmq.temp3.repository.base;

import com.rocketmq.temp3.entity.po.Customer;
import com.rocketmq.temp3.entity.po.Product;
import com.rocketmq.temp3.entity.support.AppGenId;
import com.rocketmq.temp3.entity.support.AppGenKey;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.IdsMapper;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

@Configuration
public class RepositoryConfig {
    /**
     * 分布式全局唯一Key生成策略
     */
    @Bean
    public AppGenId appGenId(AppGenKey genKey) {
        AppGenId appGenId = new AppGenId();
        appGenId.setGenKey(genKey);
        return appGenId;
    }

    @Bean
    public BaseDao<Customer> customerBaseDao(Mapper<Customer> mapper, MySqlMapper<Customer> mySqlMapper, IdsMapper<Customer> idsMapper) {
        return new BaseDao<Customer>(mapper, mySqlMapper, idsMapper) {
        };
    }

    @Bean
    public BaseDao<Product> productBaseDao(Mapper<Product> mapper, InsertListMapper<Product> mySqlMapper, IdsMapper<Product> idsMapper) {
        return new BaseDao<Product>(mapper, mySqlMapper, idsMapper) {
        };
    }

}
